<?php

/**
 * 产品规格价格表 "{{pro_spe}}".
 *
 * The followings are the available columns in table '{{pro_spe}}':
 * @property integer $zps_id     ID
 * @property integer $zp_id      产品ID
 * @property integer $zpa_id     规格ID
 * @property double $zps_price   价格
 * @property integer $zps_min    最小数量
 * @property integer $zps_max    最大数量
 */
class ProSpe extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return ProSpe the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{pro_spe}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('zp_id, zpa_id, zps_min, zps_max', 'numerical', 'integerOnly'=>true),
			array('zps_price', 'match','pattern'=>'/^[1-9]\\d*.\\d*|0.\\d*[1-9]\\d*$/'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('zps_id, zp_id, zpa_id, zps_price, zps_min, zps_max', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'zps_id' => 'Zps',
			'zp_id' => 'Zp',
			'zpa_id' => 'Zpa',
			'zps_price' => 'Zps Price',
			'zps_min' => 'Zps Min',
			'zps_max' => 'Zps Max',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('zps_id',$this->zps_id);
		$criteria->compare('zp_id',$this->zp_id);
		$criteria->compare('zpa_id',$this->zpa_id);
		$criteria->compare('zps_price',$this->zps_price);
		$criteria->compare('zps_min',$this->zps_min);
		$criteria->compare('zps_max',$this->zps_max);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}